New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pre/postEventFunction to addDebugHook #126
Add pre/postEventFunction to addDebugHook #126
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice stuff. I've suggested a thing or two, but if you've given this thorough testing, feel free to adjust the labels and give this a merge 🚢 🇮🇹 (:shipit:)
@@ -132,7 +136,7 @@ bool CDebugHookManager::RemoveDebugHook( EDebugHookType hookType, const CLuaFunc | |||
/////////////////////////////////////////////////////////////// | |||
void CDebugHookManager::OnLuaMainDestroy( CLuaMain* pLuaMain ) | |||
{ | |||
for( uint hookType = EDebugHook::PRE_EVENT ; hookType <= EDebugHook::POST_FUNCTION ; hookType++ ) | |||
for( uint hookType = EDebugHook::PRE_EVENT ; hookType <= EDebugHook::POST_EVENT_FUNCTION ; hookType++ ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could DUMMY_LAST_DEBUG_HOOK
be used here, and defined where the enums are defined?
@@ -193,6 +193,9 @@ bool CMapEventManager::Call ( const char* szName, const CLuaArguments& Arguments | |||
if ( bEnabled ) | |||
g_pCore->LogEvent ( 0, "Lua Event", pMapEvent->GetVM ()->GetScriptName (), szName ); | |||
|
|||
if ( !g_pClientGame->GetDebugHookManager()->OnPreEventFunction( szName, Arguments, pSource, NULL, pMapEvent ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is nullptr
possible?
ae75dd8
to
3c046f8
Compare
I don't have any usecase for this anymore personally. Does anybody need this? If not, then there is no reason to merge this. |
What was your use-case? |
To measure CPU usage for onClientRender per resource/eventhandler, which you can't do with onPreEvent onPostEvent. |
I feel that giving scripters and server owners profiling tools like this can't hurt, neither be a bloat, but indeed it can be something useful to gather information about how are concrete parts of a resource behaving. Talking about the particular use-case that @Necktrox mentioned, I think that onClientRender can be a major performance bottleneck for the server when not so well designed algorithms are in place or just when a need to do extremely frequently operations arises (depending on the gamemode, it may be necessary to tie some logic at the execution speed of the game. And it could happen that one big resource does those operations). One could argue that in well designed scripts that shouldn't be a performance hog, and it would be right. But at least this PR would provide people who design that performance hogs tools to prove that they are doing something wrong, right? Besides, CPU usage can be a concern for server owners (albeit unlikely sor a MTA server alone), so anything that could give them more factual data about how are the CPU cycles being used seems welcome. |
What's possible: Same examples, but hosted on GitHub Gist: |
This PR adds, see title, two new debug hook types called preEventFunction and postEventFunction. You can now have greater control over event handling throughout your entire server if you want to debug your own implemented functionality in this region.
Wiki: addDebugHook